<template>
	<view class="wrap u-p-t-0">
    <view class="u-tabs-box">
				<u-tabs-swiper activeColor="#f29100" ref="tabs" :list="list" :current="current" @change="change" :is-scroll="false" swiperWidth="750"></u-tabs-swiper>
			</view>
			<swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
				<swiper-item class="swiper-item">
					<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
						<u-form :model="model" ref="uForm" :errorType="errorType">
			<u-form-item label-width="150" :label-position="labelPosition" label="申请人" prop="name">
				<u-input :border="border" placeholder="请输入申请人姓名" v-model="model.name" type="text"></u-input>
			</u-form-item>
			<u-form-item label-width="150" :label-position="labelPosition" label="部门" prop="sex">
				<u-input :border="border" type="select" :select-open="actionSheetShow" v-model="model.sex" placeholder="请选择部门" @click="actionSheetShow = true"></u-input>
			</u-form-item>
			<u-form-item label-width="150" :label-position="labelPosition" label="请假类型" prop="sex">
				<u-input :border="border" type="select" :select-open="actionSheetShow" v-model="model.sex" placeholder="请选择请假类型" @click="actionSheetShow = true"></u-input>
			</u-form-item>
			<u-form-item label-width="150" :label-position="labelPosition" label="起始时间" prop="time">
				<u-input type="picker" @click="timerShow=true" v-model="model.timer" placeholder="请选择请假起始时间"></u-input>
			</u-form-item>
			<u-form-item label-width="150" :label-position="labelPosition" label="结束时间" prop="time">
				<u-input type="picker" @click="timerShow=true" v-model="model.timer" placeholder="请选择请假结束时间"></u-input>
			</u-form-item>
			
			<u-form-item label-width="150" :label-position="labelPosition" label="请假事由" prop="intro">
				<u-input type="textarea" :border="border" placeholder="请填写请假事由" v-model="model.intro" />
			</u-form-item>
			<view class="process">
				<view class="title fs16">流程</view>
				<view class="processList">
					<u-time-line>
							<u-time-line-item nodeTop="2">
								<!-- 此处自定义了左边内容，用一个图标替代 -->
								<template v-slot:node>
									<view class="u-node">
										<!-- 此处为uView的icon组件 -->
										<u-icon name="checkmark-circle-fill" size="20px" color="#19be6b" :size="24"></u-icon>
									</view>
								</template>
								<template v-slot:content>
									<view class="u-flex">
										<view class="u-flex-1">
											<view>队站值班干部</view>
										</view>
										<view>
											李队长
										</view>
									</view>
								</template>
							</u-time-line-item>
							<u-time-line-item>
								<!-- 此处没有自定义左边的内容，会默认显示一个点 -->
								<template v-slot:content>
									<view class="u-flex">
										<view class="u-flex-1">
											<view>值班干部审批</view>
										</view>
										<view>
											刘队长
										</view>
									</view>
								</template>
							</u-time-line-item>
							<u-time-line-item>
								<template v-slot:content>
									<view class="u-flex">
										<view class="u-flex-1">
											<view>政治工作科审批</view>
										</view>
										<view>
											张政委
										</view>
									</view>
								</template>
							</u-time-line-item>
							<u-time-line-item>
								<template v-slot:content>
									<view class="u-flex">
										<view class="u-flex-1">
											<view>政治部审批</view>
										</view>
										<view>
											周政委
										</view>
									</view>
								</template>
							</u-time-line-item>
						</u-time-line>
				</view>
			</view>
			<view class="footBtn">
				<u-button @click="submit" type="success">提交</u-button>
			</view>
		</u-form>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiper-item leaveLog">
					<scroll-view scroll-y style="height: 100%;width: 100%;" @scrolltolower="reachBottom">
            <view class="item">
              <view class="u-flex">
                <view class="u-flex-1 fs16">XXX的请假申请</view>
                <view class="fs12 c999">2021.08.02</view>
              </view>
              <view class="fs12 c999">部门：基层人员</view>
               <view class="fs12 c999">申请人：伍子胥</view>
               <view class="fs12 c999">请假类型：调休</view>
               <view class="fs12 c999">状态：<text class="green">审核中</text></view>
               <view class="u-text-right">
                 <u-button type="warning" size="mini">撤销</u-button>
               </view>
            </view>
					</scroll-view>
				</swiper-item>
				</swiper-item>
			</swiper>
		<u-action-sheet :list="actionSheetList" v-model="actionSheetShow" @click="actionSheetCallback"></u-action-sheet>
		<u-action-sheet :list="personLiable" v-model="personLiableShow" @click="personLiableCallback"></u-action-sheet>
		<u-select mode="single-column" :list="selectList" v-model="selectShow" @confirm="selectConfirm"></u-select>
		<u-picker mode="region"  v-model="pickerShow" @confirm="regionConfirm"></u-picker>
		<u-picker mode="time" v-model="timerShow" :params="params" @confirm="timerConfirm"></u-picker>
		<u-verification-code seconds="60" ref="uCode" @change="codeChange"></u-verification-code>
	</view>
</template>

<script>
export default {
	data() {
		let that = this;
		return {
			model: {
				name: '',
				sex: '',
				person:'',
				likeFruit: '',
				intro: '',
				payType: '支付宝',
				agreement: false,
				region: '',
				timer:'',
				goodsType: '',
				phone: '',
				code: '',
				password: '',
				rePassword: '',
				remember: false,
				photo: ''
			},
      list: [
				{
					name: '发起提交'
				},
				{
					name: '查看数据'
				},
			],
			current: 0,
			swiperCurrent: 0,
			selectList: [
				{
					value: '电子产品',
					label: '电子产品'
				},
				{
					value: '服装',
					label: '服装'
				},
				{
					value: '工艺品',
					label: '工艺品'
				}
			],
			border: false,
			check: false,
			selectStatus: 'close',
			defaultTime: '2019-12-11 20:15:35',
			checkboxList: [
				{
					name: '荔枝',
					checked: false,
					disabled: false
				},
				{
					name: '香蕉',
					checked: false,
					disabled: false
				},
				{
					name: '橙子',
					checked: false,
					disabled: false
				},
				{
					name: '草莓',
					checked: false,
					disabled: false
				}
			],
			radioList: [
				{
					name: '支付宝',
					checked: true,
					disabled: false
				},
				{
					name: '微信',
					checked: false,
					disabled: false
				},
				{
					name: '银联',
					checked: false,
					disabled: false
				},
				{
					name: '现金',
					checked: false,
					disabled: false
				}
			],
			radio: '支付宝',
			params: {
				year: true,
				month: true,
				day: true,
				hour: true,
				minute: true,
				second: true,
			},
      dx:0,
      loadStatus: ['loadmore','loadmore','loadmore','loadmore'],
			actionSheetList: [
				{
					text: '文件名'
				},
				{
					text: '会议记录'
				},
				{
					text: '领导指示'
				}
			],
			actionSheetShow: false,
			personLiable:[{text:'张科长'},{text:'指导员'}],
			personLiableShow:false,
			pickerShow: false,
			timerShow:false,
			selectShow: false,
			radioCheckWidth: 'auto',
			radioCheckWrap: false,
			labelPosition: 'left',
			codeTips: '',
			errorType: ['message'],
		};
	},
	onLoad() {

	},
	computed: {
		borderCurrent() {
			return this.border ? 0 : 1;
		}
	},
	onReady() {
		// this.$refs.uForm.setRules(this.rules);
	},
	methods: {
		submit() {
			this.$refs.uForm.validate(valid => {
				if (valid) {
					if(!this.model.agreement) return this.$u.toast('请勾选协议');
					console.log('验证通过');
				} else {
					console.log('验证失败');
				}
			});
		},

		// 选择地区回调
		regionConfirm(e) {
			this.model.region = e.province.label + '-' + e.city.label + '-' + e.area.label;
		},
		timerConfirm(e){},
		// 选择商品类型回调
		selectConfirm(e) {
			this.model.goodsType = '';
			e.map((val, index) => {
				this.model.goodsType += this.model.goodsType == '' ? val.label : '-' + val.label;
			})
		},
		reachBottom() {
			
		},
		radioCheckboxChange(index) {
			if(index == 0) {
				this.radioCheckWrap = false;
				this.radioCheckWidth = 'auto';
			} else if(index == 1) {
				this.radioCheckWrap = true;
				this.radioCheckWidth = 'auto';
			} else if(index == 2) {
				this.radioCheckWrap = false;
				this.radioCheckWidth = '50%';
			}
		},
		labelPositionChange(index) {
			this.labelPosition = index == 0 ? 'left' : 'top';
		},
		codeChange(text) {
			this.codeTips = text;
		},
		// 获取验证码
		getCode() {
			if(this.$refs.uCode.canGetCode) {
				// 模拟向后端请求验证码
				uni.showLoading({
					title: '正在获取验证码',
					mask: true
				})
				setTimeout(() => {
					uni.hideLoading();
					// 这里此提示会被this.start()方法中的提示覆盖
					this.$u.toast('验证码已发送');
					// 通知验证码组件内部开始倒计时
					this.$refs.uCode.start();
				}, 2000);
			} else {
				this.$u.toast('倒计时结束后再发送');
			}
		},
		errorChange(index) {
			if(index == 0) this.errorType = ['message'];
			if(index == 1) this.errorType = ['toast'];
			if(index == 2) this.errorType = ['border-bottom'];
			if(index == 3) this.errorType = ['border'];
		},
    	// tab栏切换
		change(index) {
			this.swiperCurrent = index;
			this.getOrderList(index);
		},
		transition({ detail: { dx } }) {
			this.$refs.tabs.setDx(dx);
		},
		animationfinish({ detail: { current } }) {
			this.$refs.tabs.setFinishCurrent(current);
			this.swiperCurrent = current;
			this.current = current;
		}
	}
};
</script>

<style scoped lang="scss">
.wrap {
	
	 height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
	.swiper-box{
		height:calc(100% - 100rpx);
		.title{
			padding:20rpx 0;
			
		}
		.swiper-item{
			padding:0 20rpx;
		}
	}
}
.process{
	margin:20rpx 0;
	.title{
		padding:20rpx 0;
		
	}
	.processList{
		padding-left:20px;
	}
}
.agreement {
	display: flex;
	align-items: center;
	margin: 40rpx 0;

	.agreement-text {
		padding-left: 8rpx;
		color: $u-tips-color;
	}
}
.m-t-20{
	margin-top:20rpx;
}
.fs16{
	font-size:32rpx;
}
.fs12{
	font-size:20rpx;
}
.leaveLog{
	background: #f8f8f8;
  .item{
	  margin-top:20rpx;
	  line-height: 40rpx;
	padding:20rpx;
    border-radius: 0.3em;
    background: #fff;
  }
}
.blue{
	color:#2979FF;
}
.green{
	color:#18B566;
}
.red{
	color:#FA3534;
}
.c999{
	color:#999;
}
.footBtn{
	
}
</style>
